
<div id="crmdeal"  style="display:none;  ">
	<form class="layui-form" action="index.php?m=crm_index&c=crmDeal" target="supportiframe" method="post" id="formCrm" onsubmit="return crmdeal()" autocomplete='off'> 
		<div class="crm_record_list" >
			<div class="crm_record_name"><span class="admin_required_icon"></span> 客户名称：</div>
			<div class="crm_record_textbox" style='width:180px;'>
				<div class="layui-form-item">
				  <div class="layui-input-inline" >
						<input type="text" class="layui-input"  name="crm_keyword" id="comname" style='width:315px;' >
						<input type="hidden"  name="com_uid" id="com_uid">
				  </div>
				</div>
				<div  class="layui-anim_al">
					<dl name="word" class="layui-anim_all" >
					</dl>
				</div>
			</div>
		</div>
		<div class="crm_record_list" >
			<div class="crm_record_name"><span class="admin_required_icon"></span> 支付方式：</div>
			<div class="crm_record_textbox" >
				<div class="layui-form-item">
					<div class="layui-input-inline" >
						<select name="order_type" id="order_type" lay-filter="order_type">
						    <option value=''></option>
 						    {yun:}foreach from = $cache.crmdata.order_type key=key item=v{/yun}
						        <option value='{yun:}$v{/yun}' title='{yun:}$cache.crmclass_name[$v]{/yun}'>{yun:}$cache.crmclass_name[$v]{/yun}</option>
			              	{yun:}/foreach{/yun}
						</select>
					</div>
				</div>
						
			</div>
		</div>
		<div class="crm_record_list" >
			<div class="crm_record_name"><span class="admin_required_icon"></span> 选择套餐：</div>
			<div class="crm_record_textbox" >
				<div class="layui-form-item">
					<div class="layui-input-inline" >
						<select name="rid" id="rid_val" lay-filter="rid">
                            <option value="">请选择</option>
                            {yun:}foreach from = $ratinglist key=key item=v{/yun}
							<option value="{yun:}$v.id{/yun}">{yun:}$v.name{/yun}</option>
                            {yun:}/foreach{/yun}
                        </select>
					</div>
				</div>		
			</div>
		</div>
		<div class="crm_record_list" >
			<div class="crm_record_name"><span class="admin_required_icon"></span> 付款金额：</div>
			<div class="crm_record_textbox" >
				<div class="layui-form-item">
					<div class="layui-input-inline" >
						 <input type="text" name="order_price" id="order_price" size="15"  value="" class="layui-input"/>
					</div>
				</div>		
			</div>
		</div>
		<div class="crm_record_list" >
			<div class="crm_record_name"><span class="admin_required_icon"></span> 备注信息：</div>
			<div class="crm_record_textbox" style='width:80px;'>
				<div class="layui-form-item">
				  <div class="layui-input-inline" >
						<textarea id="order_remark" name="order_remark"  class="layui-textarea" style="width:315px;"></textarea>
				  </div>
				</div>
			</div>
		</div>
		<div class="crm_record_list" id="waittasksubmit">
			<span class="crm_record_name">&nbsp;</span>
			<div class="crm_record_textbox"  style='width:315px;' >
				<input type="hidden" name="id" id="edittaskid" value="">
				<input type="hidden" name="order_id" id="orderid" value="">
				<input type="submit"  value='确认' class="admin_examine_bth"><input type="button"  onClick="layer.closeAll();" class="admin_examine_bth_qx" value='取消' style="margin-left:10px;">
			</div> 	
		</div> 
		<input type="hidden" name="pytoken" id="pytoken" value="{yun:}$pytoken{/yun}">
	</form> 
</div>
<div id="crmwaittask"  style="display:none; width:450px; ">
	<form class="layui-form" action="index.php?m=crm_waitingtask&c=add" target="supportiframe" method="post" onsubmit="return crmwaittask()" autocomplete='off'>
		<div class="crm_record_list" >
		<div class="crm_record_name"><span class="admin_required_icon"></span> 客户名称：</div>
			<div class="crm_record_textbox">
				<div class="layui-form-item">
				  <div class="layui-input-inline" style="width:315px" >
					<input type="text" class="layui-input" name="crm_keyword"  style='width:315px;'>
					<input type="hidden"  name="com_uid" >
				  </div>
				 </div>
				 <div  class="layui-anim_al">
					<dl name="word" class="layui-anim_all" >
					 </dl>
				 </div>
			</div>
		</div>
		
		<div class="crm_record_list">
			<div class="crm_record_name"><span class="admin_required_icon"></span>任务标题：</div>
			<div class="crm_record_textbox">
				<div class="layui-form-item">
					<div class="layui-inline">
						<div class="layui-input-inline">
							<input type="text" class="layui-input" id='title' name='title'  style='width:315px;'>
						</div>
					</div>
				</div>
					
			</div>
		</div>
		
		<div class="crm_record_list">
			<div class="crm_record_name"><span class="admin_required_icon"></span>任务时间：</div>
			<div class="crm_record_textbox">
				<div class="layui-form-item">
					<div class="layui-inline">
						<div class="layui-input-inline">
							<input type="text" class="layui-input" id='stime' name='stime' placeholder="yyyy-MM-dd HH:mm:ss" style='width:315px;'>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<div class="crm_record_list">
			<div class="crm_record_name"><span class="admin_required_icon"></span>任务描述：</div>
			
			<div class="crm_record_textbox">
				<textarea  id="content" name="content" cols="100" rows="4"  class="layui-textarea"></textarea>
			</div>
		</div>
		<div class="crm_record_list" id="waittasksubmit">
			<span class="crm_record_name">&nbsp;</span>
            <div class="crm_record_textbox">
			<input type="hidden" name="id" id="edittaskid" value="">
			<input type="submit"  value='确认' class="admin_examine_bth"><input type="button"  onClick="layer.closeAll();" class="admin_examine_bth_qx" value='取消' style="margin-left:10px;">
		</div> 	</div> 
		<input type="hidden" name="pytoken" value="{yun:}$pytoken{/yun}">
	</form> 
</div>
<div id="crmworklog"  style="display:none; width:450px; ">
		<form class="layui-form" action="index.php?m=crm_worklog&c=add" target="supportiframe" method="post" onsubmit="return crmworklog()" autocomplete='off'>
			<div class="crm_record_list">
					<div class="crm_record_name" style="width: 200px;"><span class="admin_required_icon" >注意：提交后将不能修改！</span></div>
					
				</div>
			<div class="crm_record_list">
				<div class="crm_record_name"><span class="admin_required_icon"></span>日志标题：</div>
				<div class="crm_record_textbox">
					<div class="layui-form-item">
						<div class="layui-inline">
							<div class="layui-input-inline">
								<input type="text" class="layui-input" id='logtitle' name='logtitle'  style='width:315px;'>
							</div>
						</div>
					</div>
						
				</div>
			</div>
			<div class="crm_record_list">
				<div class="crm_record_name"><span class="admin_required_icon"></span>日志内容：</div>
				
				<div class="crm_record_textbox" >
					<textarea id="logcontent" name="logcontent"  class="layui-textarea" style="width:500px;height:200px;"></textarea>
				</div>
			</div>
			<div class="crm_record_list">
				<span class="crm_record_name">&nbsp;</span>
				<div class="crm_record_textbox">
				<input type="submit"  value='确认' class="admin_examine_bth"><input type="button"  onClick="layer.closeAll();" class="admin_examine_bth_qx" value='取消' style="margin-left:10px;">
			</div> 	</div> 
			<input type="hidden" name="pytoken" value="{yun:}$pytoken{/yun}">
		</form> 
	</div>
<div id='crmcom' style='display:none;'>
	<table class="layui-table" lay-skin='line'>
			<colgroup>
			<col width="100">
			<col width="250">
			</colgroup>
			<tbody>
			<tr><td>客户名称：</td><td id='crmcomname'></td></tr>
			<tr><td>会员等级：</td><td id='comrating'></td></tr>
			<tr><td>到期时间：</td><td id='comratingtime'></td></tr>
			<tr><td>所在城市：</td><td id='comcityname'></td></tr>
			<tr><td>联系人：</td><td id='comlinkman'></td></tr>
			<tr><td>联系手机：</td><td id='commoblie'></td></tr>
			</tbody>
	</table>
</div>
<style>
.layui-anim_al {
    position: absolute;
    z-index: 2147483647;
    min-width: 315px;
    max-height: 300px;
    overflow-y: auto;
    background-color: white;
    border-radius: 2px;
    box-shadow: 0 2px 4px hsla(0, 0%, 0%, .12);
    box-sizing: border-box;
}
.layui-anim_al dl dd, .layui-anim_al dl dt {
    padding: 0 10px;
    line-height: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.click_work {
    padding-bottom: 8px;
    font-weight: lighter;
    font-size: 13px;
    cursor: pointer;
}
</style>
<script>
	
layui.use(['form', 'laydate'], function(){
	var form = layui.form
		,laydate = layui.laydate
		,$ = layui.$;
		var pytoken = $('#pytoken').val();
		form.on('select(rid)', function(data) {
           $.post("index.php?m=crm_index&c=orderprice", {id:data.value, pytoken: pytoken},function(data){
                if(data) {
                    var dataJson = eval("(" + data + ")");
                    $('#order_price').val(dataJson.service_price); 
                } 
                form.render('select');
            });
        });	
	laydate.render({
		elem: '#stime'
		,type: 'datetime'
	});
});

	var weburl="{yun:}$config.sy_weburl{/yun}";
 $('input[name="crm_keyword"]').keyup(function(){
	var pytoken = $('#pytoken').val();
	var comname=$.trim($(this).val());
	if(comname==''){
		$('.layui-anim_al').hide();
		$('input[name="com_uid"]').val('');
	}
	$.ajax({
		url: weburl+'/admin/index.php?m=crm_index&c=searchcom',
		data: {keyword:comname,pytoken:pytoken},
		type: 'post',
		dataType: 'JSON',
			async: false,
		success:function(data){
			var html="";
			if(data){
				for(var i=0;i<data.length;i++){
					html+='<dd lay-value="" class="layui-select-tips"><div class="click_work" data-uid="'+data[i].uid+'">'+data[i].name+'</div></div>';
				}
				$('.layui-anim_all').html(html);
				$('.layui-anim_al').show();
			}else{
				if(comname){
					html='<dd lay-value="" class="layui-select-tips"><div class="click_work" >无相关客户</div></div>';
						$('.layui-anim_all').html(html);
					$('.layui-anim_al').show();
					$('input[name="com_uid"]').val('');
				}else{
					$('.layui-anim_al').hide();
					$('input[name="com_uid"]').val('');
				}	
			}
		}
	})
})
$(document).on('click','.click_work',function(){
	var comuid=$(this).attr('data-uid');
	$('input[name="crm_keyword"]').val($(this).text());
	$('.layui-anim_al').hide();
	$('input[name="com_uid"]').val(comuid); 
})
</script>